     AMSTRAD COMPUTER USER MAGAZINE
        AUG/SEP 1984 - ISSUE 001

----------------------------------------
001 - The Surprise Listing!!
----------------------------------------

Every now and again we shall produce an anonymous listing with unforseen 
results. Here's the first. And don't complain to the editor if you reckon 
it's a waste of time, some people will type in anything...

----------------------------------------

10 INK 1,6:INK 2,24:INK 3,24:INK 4,1:INK 5,1:INK 6,24:INK 8,1:INK 9,1:INK 
10,24:INK 11,1:INK 12,1:INK 13,1:INK 14,24:INK 15,1
20 co=1
30 MODE 0
40 ORIGIN 70,0
50 GOSUB 1070
60 REM
70 REM load outline data
80 READ a,b
90 IF a<>999 THEN 130
100 a=b
110 READ b
120 MOVE b,a*2
130 IF a=1000 THEN 160
140 DRAW b,a*2,1
150 GOTO 80
160 READ aa,ab,ac,y
170 FOR s=1 TO 13
180 READ x
190 MOVE x,y*2
200 DRAWR 0,-(aa*2)
210 DRAWR ab,0
220 DRAWR 0,aa*2
230 NEXT s
240 REM
250 RESTORE 650
260 READ b,a
270 IF b<>999 THEN 310
280 b=a
290 READ a
300 MOVE a,b*2
310 IF b=1000 THEN 800
320 DRAW a,b*2,2
330 GOTO 260
340 DATA 
999,2,28,2,464,12,464,12,28,2,28,999,14,56,18,56,18,436,14,436,999,86,56,86,436,102,436,102,56,86,56
350 DATA 999,12,36,134,36,134,44,12,44,999,18,72,86,72,999,18,420,86,420
360 DATA 999,134,80,134,28,140,28,140,88,136,96,124,96,124,84,132,84,134,80
370 DATA 
999,134,28,130,20,130,8,134,0,140,0,144,8,144,20,140,28,999,138,20,136,20,134,16,134,12,136,8,138,8,140,12,140,16,138,20
380 DATA 
999,96,80,92,80,90,76,90,68,92,64,96,64,98,68,98,76,96,80,999,96,428,92,428,90,424,90,416,92,412,96,412,98,416,98,424,96,428
390 DATA 1000,1000
400 DATA 64,12,64,86,96,120,144,168,192,216,240,264,288,312,336,360,384
410 INK 1,6:INK 2,24:INK 6,24:INK 12,1:INK 8,1:INK 3,24
420 INK 4,1:INK 10,24
430 INK 13,1:INK 15,1
440 INK 9,2-ABS(co-1):INK 5,2-ABS(((co+1)MOD(3))-1):INK 
11,2-ABS(((co+2)MOD(3))-1)
450 co=(co+1)MOD(3)
460 FOR x=1 TO 150:NEXT x
470 INK 13,14
480 INK 9,2-ABS(co-1):INK 5,2-ABS(((co+1)MOD(3))-1):INK 
11,2-ABS(((co+2)MOD(3))-1)
490 INK 2,1:INK 4,24
500 INK 10,1:INK 12,24:INK 3,6:co=(co+1)MOD(3)
510 FOR x=1 TO 150:NEXT x
520 INK 9,2-ABS(co-1):INK 5,2-ABS(((co+1)MOD(3))-1):INK 
11,2-ABS(((co+2)MOD(3))-1)
530 INK 15,14
540 INK 4,1:INK 8,24
550 INK 6,1:INK 10,24
560 co=(co+1)MOD(3)
570 FOR x=1 TO 150:NEXT x
580 INK 9,2-ABS(co-1):INK 5,2-ABS(((co+1)MOD(3))-1):INK 
11,2-ABS(((co+2)MOD(3))-1)
590 INK 13,1
600 INK 8,1:INK 4,24
610 INK 6,24:INK 10,1
620 FOR x=1 TO 150:NEXT x
630 co=(co+1)MOD(3)
640 GOTO 410
650 DATA 
999,134,240,134,224,132,220,132,216,126,204,124,204,122,200,114,200,112,204,110,204,104,216,104,220,999,104,252,104,256,106,260,108,260,110,264,118,264
660 DATA 
110,264,108,268,106,268,104,272,104,276,999,104,308,104,312,110,324,112,324,114,328,122,328,124,324,126,324,132,312,132,308,134,304
670 DATA 
134,292,999,120,232,116,232,999,118,228,118,236,999,120,300,116,300,999,118,296,118,304
680 DATA 
999,142,240,164,240,164,232,174,232,174,240,182,240,182,296,142,296,154,320,182,320,194,296,194,244,180,216,154,216,142,240
690 DATA 
999,140,240,140,216,134,204,132,204,130,200,128,196,126,196,122,188,120,188,118,184,116,180,114,180,108,168
700 DATA 
98,168,98,200,106,200,106,168,999,98,176,102,176,999,102,184,98,184,999,102,192,98,192
710 DATA 
999,140,248,140,284,999,140,292,140,316,136,324,134,324,130,332,128,332,124,340,122,340,120,344
720 DATA 
116,344,114,348,112,348,108,356,98,356,98,324,106,324,106,356,999,102,348,98,348,999,98,340,102,340,999,102,332,98,332
730 DATA 
999,174,268,174,256,166,256,166,264,172,264,172,260,168,260,999,174,288,174,276,166,276,166,284,172,284,172,280,168,280
740 DATA 
999,162,264,162,276,158,276,158,268,999,154,276,150,276,150,264,154,264,152,268,152,272,154,276
750 DATA 
999,150,224,164,224,999,170,224,184,224,999,184,232,152,232,999,148,232,146,232
760 DATA 
999,182,240,186,240,999,190,240,192,240,999,194,248,182,248,999,194,256,186,256,999,194,264,192,264,999,188,264,182,264
770 DATA 
999,194,272,182,272,999,194,280,188,280,999,184,280,182,280,999,182,288,190,288,999,194,296,182,296
780 DATA 
999,190,304,180,304,999,174,304,156,304,999,152,304,146,304,999,150,312,162,312,999,168,312,186,312
790 DATA 1000,1000
800 RESTORE 650
810 PRINT CHR$(23);CHR$(3)
820 READ b,a
830 IF b<>999 THEN 870
840 b=a
850 READ a
860 MOVE a,(b*2)-40
870 IF b=1000 THEN 940
880 IF b*2-40<208 THEN 910
890 DRAW a,(b*2)-40,4
900 GOTO 820
910 READ b,a
920 IF b=999 THEN 840
930 GOTO 860
940 RESTORE 650
950 READ b,a
960 IF b<>999 THEN 1000
970 b=a
980 READ a
990 MOVE a,(b*2)-80
1000 IF b=1000 THEN 400
1010 IF b*2-80<208 THEN 1040
1020 DRAW a,(b*2)-80,8
1030 GOTO 950
1040 READ b,a
1050 IF b=999 THEN 970
1060 GOTO 990
1070 SYMBOL 244,96,248,252,254,126,63,15,0
1080 SYMBOL 249,48,120,120,124,60,30,14,6
1090 SYMBOL 247,6,15,31,30,62,60,120,32
1100 SYMBOL 246,4,14,15,31,62,60,112,192
1110 SYMBOL 245,24,24,60,126,60,24
1120 PEN 13
1130 LOCATE 7,12:PRINT CHR$(249)
1140 LOCATE 15,12:PRINT CHR$(247)
1150 PEN 15
1160 LOCATE 3,11:PRINT CHR$(244)
1170 LOCATE 5,7:PRINT CHR$(244)
1180 LOCATE 17,11:PRINT CHR$(246)
1190 LOCATE 17,7:PRINT CHR$(246)
1200 MOVE 88,240:DRAW 88,240,11
1210 TAG:MOVE 80,246:PRINT CHR$(245);
1220 MOVE 88,226:DRAW 88,226,5
1230 MOVE 80,232:PRINT CHR$(245);
1240 MOVE 88,212:DRAW 88,212,9
1250 MOVE 80,218:PRINT CHR$(245);:TAGOFF
1260 RETURN

----------------------------------------
*************** Programs ***************
----------------------------------------

In this issue, we present three very different programs that have one thing 
in common: they all illustrate the tremendous power of the CPC464 and show 
just how much can be achieved with really quite short programs written in 
BASIC.

In this, the first issue of the User Club magazine, we start a regular 
feature with a double aim: to present programs for you to type in and try 
out on your CPC464, and in so doing, to explain some of the programming 
techniques used. The level of explanation will range from the very simple 
(to help the beginning programmer) to more detailed descriptions of some of 
the advanced techniques used by experienced programmers. In this way, we 
hope that you will gain insights that the text books often miss out, and at 
the same time have fun using your new computer in a constructive way.
We have a three dimensional drawing program from David Robinson of Saxon 
Computing that is quite unusually compact for such a sophisticated 
application. Another graphics program exploits the window capabilities of 
the CPC464 and shows how easy it all can be.
Finally, we have a short program for producing colour bar charts and other 
patterns for examining the performance of TVs and monitors. Don't be 
surprised to find that the performance of the dedicated CTM640 monitor is 
superior to the modulator/TV combination.

----------------------------------------
002 - Windows
----------------------------------------

This program demonstrates the ease with which 'windows' (separately 
addressable portions of the screen) and be set up and written to (lines 160, 
230 and 240) After the windows have been set up and had the relevant 
captions and axes drawn in, initial values for the variables used in the 
subroutines are established in lines 350 and 360.
The code from lines 410 to 430 are much like the ordinary subroutine calls 
except that the EVERY statement is used. EVERY allows subroutines to be 
called at regular, specified intervals. The interval is specified by the 
first argument, and the number of the timer by the second. The EVERY 
statement calls the subroutine associated with it after the specified delay 
has elapsed. Each delay interval is 1/50th of a second.
Line 420, therefore, calls the ellipse subroutine every 0.1 seconds; the 
associated timer is number 1. For a complete description of the EVERY 
command, refer to chapter 10, page 2 of the user instruction book. Note also 
the use of DI (Disable Interrupts) and EI (Enable Interrupts) in the ellipse 
and bargraph routines. Try REMing these out to see the effect. Another 
important line is 440 GOTO 440 The program will not work if this is taken 
out (by REM). Can you see why?
The three subroutines are all fairly straightforward and can easily be 
adapted for use in other programs. Instead of using the RND (random) 
function (line 770) to set the height of the bars, the value of T could be 
supplied from other parts of the your program to make a very easy and 
efficient bargraph generator.

----------------------------------------

10 REM ******************************
20 REM ******************************
30 REM **USING WINDOWS AND GRAPHICS**
40 REM ******************************
50 REM ******************************
60 REM
70 MODE 2
80 CLS
90 BORDER 26
100 INK 0,20
110 INK 1,1
120 REM
130 REM ******************************
140 REM ***     CREATE WINDOWS     ***
150 REM ******************************
160 WINDOW #1,3,52,2,12
170 PLOT 10,10
180 DRAW 420,10,1
190 DRAW 420,196,1:DRAW 10,196:DRAW 10,10
200 PLOT 10,206:DRAW 420,206:DRAW 420,390:DRAW 10,390:DRAW 10,206
210 PLOT 430,10:DRAW 630,10:DRAW 630,390:DRAW 430,390:DRAW 430,10
220 PLOT 410,230:DRAW 26,230:DRAW 26,310
230 WINDOW #2,3,52,14,24
240 WINDOW #3,56,78,2,24
250 PRINT #1,"WINDOW No 1: Using windows and graphics in Mode 2.***RANDOM 
BAR-GRAPHS***"
260 PRINT #2,"WINDOW No 2:                                      ***PLOTTING 
A SINE WAVE***"
270 PRINT #3,"WINDOW No 3:           ***ELIPSES***"
280 PLOT 20,65:DRAW 400,65
290 PLOT 440,140:DRAW 620,140:PLOT 530,40:DRAW 530,240
300 LOCATE 4,12:PRINT "JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC"
310 REM
320 REM ******************************
330 REM ***    SET UP VARIABLES    ***
340 REM ******************************
350 a=0:n=-680
360 m=1
370 REM
380 REM ******************************
390 REM ***    SUBROUTINE CALLS    ***
400 REM ******************************
410 EVERY 5,1 GOSUB 600:     'Ellipse
420 EVERY 3,2 GOSUB 490:     'Sinewave
430 EVERY 130,3 GOSUB 720:   'Bar-graph
440 GOTO 440
450 REM
460 REM ******************************
470 REM ***  SINEWAVE SUBROUTINE   ***
480 REM ******************************
490 DEG:ORIGIN 200,65
500 y=SIN(n)
510 PLOT n*0.25,50*y
520 n=n+2
530 IF n=680 THEN GOTO 880
540 LET lp=lp+1
550 RETURN
560 REM
570 REM ******************************
580 REM ***   ELLIPSE SUBROUTINE   ***
590 REM ******************************
600 DI:              'Disable interrupt
610 DEG:ORIGIN 530,140
620 PLOT 50*COS(a),60*SIN(a)
630 PLOT 60*COS(a),60*SIN(a)
640 PLOT 70*COS(a),60*SIN(a)
650 a=a+2
660 EI:              'Enable interrupt
670 RETURN
680 REM
690 REM ******************************
700 REM **RANDOM BARGRAPH SUBROUTINE**
710 REM ******************************
720 DI
730 IF m>12 THEN RETURN
740 ORIGIN 0,0
750 x=m*32
760 y=230
770 t=INT(RND(1)*80)
780 PLOT x,y:DRAW x+10,y:DRAW x+20,y+10
790 DRAW x+20,y+t+10:DRAW x+10,y+t+10
800 DRAW x,y+t:DRAW x,y:DRAW x+10,y
810 DRAW x+10,y+t
820 DRAW x+20,y+t+10:DRAW x,y+t
830 DRAW x+10,y+t
840 m=m+1
850 EI
860 RETURN
870 REM End of program routine
880 PRINT CHR$(7):  'Beep when finished
890 IF INKEY$="" THEN 890:  'Do nothing                    until key is 
pressed
900 CLS:END


----------------------------------------
003 - Test Patterns
----------------------------------------

There are six different display options, similar to those generated by TV 
test pattern generators used for aligning colour TV equipment. Lines 170 to 
240 use INKEY$ to read a number from 1 to 6 from the keyboard (to select the 
option) and then branch to the appropriate routine.
After the routine has been selected, the program will 'hang' there as a 
result of the n GOTO n command which terminates each routine. The chosen 
pattern will then stay on the screen until the [ESC] key has been pressed 
twice. Note, however that we have REMed out line 50 so that you can break 
the program using the [ESC] key. (The alternative form of REM, an 
apostrophe, is used in line 50.). If line 50 was not disabled by REM, you 
could not then break from the program to check the listing or change it, 
unless BASIC tripped over an error-and there may not be one if you have been 
conscientious. Always remember to save yourself a breakable copy of programs 
where you use the ON BREAK command.
Note that the same crosshatch subroutine at line 750 is used in Mode 0 for 
the crosshatch pattern, and in Mode 2 for the bandwidth/geometry pattern, 
demonstrating the compatibility of the graphics coordinates between 
different screen modes.
Note also the SPEED INK statement in lines 60 and 700. This determines the 
speed at which alternate colours will flash.
Finally when you have tested each routine for correct operation, you may 
unREM line 50 by deleting the apostrophe. Remember then to save the program 
onto cassette if you wish to keep, or further develop it, as once you RUN 
the program, the only way you will be able to break from it, will be by 
resetting the computer.

----------------------------------------

10 REM ******* TEST  PATTERNS *******
20 REM ******* by Ivor Spital *******
30 REM **** (c)AMSTRAD CONSUMER  ****
40 REM **** ELECTRONICS PLC.1984 ****
50 ON BREAK GOSUB 820
60 SPEED INK 20,20
70 MODE 1:BORDER 1:INK 0,1:INK 1,24:INK 2,1,24:PAPER 0:PEN 1
80 PRINT TAB(9) "AMSTRAD CPC-464 SYSTEM"
90 PRINT:PRINT TAB(6) "Computer/Monitor Test Pattern"
100 LOCATE 10,10:PRINT "1 Crosshatch"
110 LOCATE 10,12:PRINT "2 Low Frequency"
120 LOCATE 10,14:PRINT "3 Colour bar"
130 LOCATE 10,16:PRINT "4 Bandwidth/Geometry"
140 LOCATE 10,18:PRINT "5 Colour Purity/Sound"
150 LOCATE 10,20:PRINT "6 RGB Alignment"
160 LOCATE 16,25:PEN 2:PRINT "Select?";:PEN 1
170 a$=INKEY$:IF a$="" THEN 170
180 IF a$="1" THEN 250
190 IF a$="2" THEN 290
200 IF a$="3" THEN 370
210 IF a$="4" THEN 500
220 IF a$="5" THEN 640
230 IF a$="6" THEN 680
240 GOTO 170
250 REM ***** CROSSHATCH PROGRAM *****
260 REM ******************************
270 MODE 0:GOSUB 750
280 GOTO 280
290 REM *** LOW FREQUENCY PROGRAM  ***
300 REM ******************************
310 MODE 0:BORDER 0:INK 0,0:INK 1,26:PAPER 0:PEN 1
320 FOR y=1 TO 25 STEP 2:FOR x=1 TO 20 STEP 2
330 LOCATE x,y:PRINT CHR$(143);:NEXT:NEXT
340 FOR y=2 TO 25 STEP 2:FOR x=2 TO 20 STEP 2
350 LOCATE x,y:PRINT CHR$(143);:NEXT:NEXT
360 GOTO 360
370 REM ***** COLOUR BAR PROGRAM *****
380 REM ******************************
390 MODE 0:BORDER 0
400 INK 0,0:INK 1,25:INK 2,23:INK 3,21:INK 4,17:INK 5,6:INK 6,2:INK 7,26
410 PAPER 0:CLS
420 PAPER 1:WINDOW 2,4,1,18:CLS
430 PAPER 2:WINDOW 5,7,1,18:CLS
440 PAPER 3:WINDOW 8,10,1,18:CLS
450 PAPER 4:WINDOW 11,13,1,18:CLS
460 PAPER 5:WINDOW 14,16,1,18:CLS
470 PAPER 6:WINDOW 17,19,1,18:CLS
480 PAPER 7:WINDOW 2,19,19,25:CLS
490 GOTO 490
500 REM * BANDWIDTH/GEOMETRY PROGRAM *
510 REM ******************************
520 MODE 2:GOSUB 750:ORIGIN 0,0:FOR c=0 TO 360:DEG:PLOT 320,200
530 PLOT 320+190*COS(c),200+190*SIN(c):NEXT:WINDOW 21,60,8,18
540 PAPER 1:PEN 0:CLS:FOR y=287 TO 110 STEP -1
550 FOR x=160 TO 200 STEP 9:PLOT x,y,0:NEXT
560 FOR x=200 TO 240 STEP 8:PLOT x,y,0:NEXT
570 FOR x=240 TO 280 STEP 7:PLOT x,y,0:NEXT
580 FOR x=280 TO 320 STEP 6:PLOT x,y,0:NEXT
590 FOR x=320 TO 360 STEP 5:PLOT x,y,0:NEXT
600 FOR x=360 TO 400 STEP 4:PLOT x,y,0:NEXT
610 FOR x=400 TO 440 STEP 3:PLOT x,y,0:NEXT
620 FOR x=440 TO 480 STEP 2:PLOT x,y,0:NEXT:NEXT
630 GOTO 630
640 REM *COLOUR PURITY/SOUND PROGRAM *
650 REM ******************************
660 INK 0,6:BORDER 6:PAPER 0:CLS
670 SOUND 1,200,40,7:FOR t=1 TO 1000:NEXT:GOTO 670
680 REM *** RGB ALIGNMENT PROGRAM  ***
690 REM ******************************
700 MODE 1:BORDER 1:SPEED INK 5,5:INK 0,1:INK 1,18,6:PAPER 0:PEN 1
710 MOVE 20,0:DRAW 20,398,1:MOVE 0,378:DRAW 638,378,1
720 MOVE 618,398:DRAW 618,0,1:MOVE 638,20:DRAW 0,20,1
730 MOVE 320,0:DRAW 320,398,1:MOVE 0,199:DRAW 640,199,1
740 GOTO 740
750 REM *** CROSSHATCH SUBROUTINE  ***
760 REM ******************************
770 BORDER 26:INK 0,0:INK 1,26:PAPER 0:PEN 1
780 FOR y=0 TO 400 STEP 40:IF y>390 THEN y=398
790 ORIGIN 0,y:DRAW 638,0,1:NEXT
800 FOR x=0 TO 640 STEP 40:IF x>630 THEN x=638
810 ORIGIN x,0:DRAW 0,398:NEXT:RETURN
820 RUN


----------------------------------------
****** CAD For Beginners - Part 1 ******
----------------------------------------

David Robinson of Saxon Computers shows how the CPC464 can produce 3D 
drawings from simple 2D sections.

Around the end of may I was asked if I'd present a graphics program which 
I'd evolved during my acquaintance with the CPC464 in the launch issue of 
AMSTRAD USER. The ideas began to flow, and then  grew into a regular column 
for the magazine on the subject of computer graphics, and so now I have a 
splendid excuse, at least once a month, to get away from writing business 
software!
Some graphics applications require so much computing that even the 
locomotive BASIC inside your 464 (just about the fastest standard 8 bit 
BASIC around) can seem a bit slow. Where a program could do with some extra 
speed I will list the program both in BASIC and PASCAL for those of you with 
the HISoft PASCAL 4T compiler.
Every program is accompanied by a full commentry and a list of suggested 
improvements and extensions for you to try out yourself. Your CPC464 has 
some very useful graphics features not found on any other micro under 500. 
These allow us to use techniques more associated with mainframe graphics 
computers than most micros. Three other important features are:-

1) a palette of 27 colours to choose from.
2) switchable screen resolution - but using a common co-ordinate base.
3) VERY IMPORTANT - the colour resolution is the same as the pixel 
resolution.

----------------------------------------
004 - 3D Wire Frame Plotter
----------------------------------------

This program of 3D drawings translates a two dimensional cross section into 
a full 3D shape. To get an idea of how it works, look at Figure 1a which 
shows the right half of the cross section of a wine glass. The left half is, 
of course, a simple mirror image, so the program does not require us to draw 
both halves. Figure 1b shows the 3D projection drawn by the computer from 
the cross section.

Significant line numbers are as follows:

Lines

60		Sets the screen at 320x200 resolution.
70-90		Sets up two text windows so that we can keep messages separate from 
the graphics.
100-110		Inintialise 3 arrays storing the co-ordinatesof points in 3D space.
120		Inintialise dx% and dy% - the co-ordinates of your 'dot cursor' - note 
that the LOGICAL co-ordinates are always expressed as though there are 
640x400 dots on the screen even though the actual resolution changes the 
screen mode. This saves you having to convert all your calculations every 
time you change screen mode.
160-260		Collect data and draw cross section on the screen.
		Branches to seperate routine at 1600 to complete computation of data for 
plotting.
300-430		Draws successive cross sections and connects each one to the 
previous section so as to form a 3D picture.
470-530		End routine.
650-890		Moves your 'dot cursor' around the screen.
930-1010	Puts data for each point into the arrays x% and y% describing the 
2D cross section.
		Draws line to previous point.
1060-1140	Accepts data on the amount of detail (FACES) in the final picture. 
Rotates the 2D cross section data in 3D space in steps of 360 degrees/FACES.

A point to note is the use of integer variables wherever possible to improve 
the speed of computataion.

You could try to make some improvements to the program along the following 
lines -

1) Draw a line along the centre of the input screen to mark the centre line 
for the cross section.
2) The 'dot cursor' will erase any previously drawn lines whilst on its 
travel about the screen. See if you can write a routine to prevent this.

Save the program on tape as we shall be using it again in later issues.

----------------------------------------

10 REM ******************************
20 REM ******************************
30 REM *WIRE FRAME GRAPHICS PLOTTER *
40 REM ******************************
50 REM ******************************
60 MODE 1
70 LOCATE 10,12:PRINT "   Press  S P A C E   B A R  to start"
80 IF INKEY$<>" " THEN 80
90 WINDOW #0,1,40,1,4:WINDOW #1,1,40,24,24
100 RAD
110 maxi%=20:DIM x%(maxi%,50):DIM y%(maxi%,50):DIM z%(maxi%,50)
120 dx%=320:dy%=0:i0%=26:i1%=0:i2%=13:i3%=6:point%=0
130 REM ******************************
140 REM *      GET PICTURE DATA      *
150 REM ******************************
160 CLS:CLS #1:CLG:BORDER i2%:INK 0,i0%:PAPER 0:INK 1,i1%:PEN 1
170 PLOT 156,0:DRAW 156,304:DRAW 494,304:DRAW 494,0
180 PRINT "USE CURSOR KEYS OR JOYSTICK TO MOVE DOT":PRINT "  PRESS ENTER OR 
FIRE TO SET A POINT."
190 PRINT "     Press Q to QUIT entering mode."
200 PLOT dx%,dy%,1
210 z%=-1*(JOY(0)=1)-2*(JOY(0)=2)-3*(JOY(0)=4)-4*(JOY(0)=8)-5*(JOY(0)=16):IF 
z%>0 THEN 250
220 z$=INKEY$:IF z$="" THEN 210
230 IF z$="Q" THEN z$=LOWER$(z$)
240 
x%=ASC(z$):z%=-1*(x%=240)-2*(x%=241)-3*(x%=242)-4*(x%=243)-5*(x%=13)-6*(x%=113)
250 ON z% GOTO 620,690,760,830,900,1020
260 GOTO 210
270 REM ******************************
280 REM *        DRAW PICTURE        *
290 REM ******************************
300 CLG
310 FOR l%=1 TO f%-1
320 FOR k%=1 TO point%-1
330 PLOT 320+x%(k%,l%),80+y%(k%,l%)-0.5*z%(k%,l%)
340 
xc%=(x%(k%,l%+1))-(x%(k%,l%)):yc%=(y%(k%,l%+1)-0.5*z%(k%,l%+1))-(y%(k%,l%)-0.5*z%(k%,l%)):DRAWR 
xc%,yc%
350 
xc=(x%(k%+1,l%+1))-(x%(k%,l%+1)):yc=(y%(k%+1,l%+1)-0.5*z%(k%+1,l%+1))-(y%(k%,l%+1)-0.5*z%(k%,l%+1)):DRAWR 
xc,yc
360 NEXT:NEXT
370 FOR l%=1 TO point%-1
380 MOVE 320+x%(l%,f%),80+y%(l%,f%)-0.5*z%(l%,f%)
390 
xc%=x%(l%,1)-x%(l%,f%):yc%=(y%(l%,1)-0.5*z%(l%,1))-(y%(l%,f%)-0.5*z%(l%,f%))
400 DRAWR xc%,yc%
410 
xc%=x%(l%+1,1)-x%(l%,1):yc%=y%(l%+1,1)-0.5*z%(l%+1,1)-y%(l%,1)-0.5*z%(l%,1)
420 DRAWR xc%,yc%
430 NEXT
440 REM ******************************
450 REM *       DRAW ANOTHER ?       *
460 REM ******************************
470 CLS #1
480 PRINT #1," DO YOU WANT TO DRAW ANOTHER PICTURE ?"
490 IF INKEY(43)=0 THEN 120
500 IF INKEY(46)=0 THEN 520
510 GOTO 490
520 MODE 1
530 END
540 REM ******************************
550 REM ******************************
560 REM **   END OF MAIN PROGRAM    **
570 REM ******************************
580 REM ******************************
590 REM
600 REM
610 REM
620 REM ******************************
630 REM *          MOVE UP           *
640 REM ******************************
650 yp%=dy%:dy%=dy%+2
660 IF dy%>300 THEN dy%=300
670 PLOT dx%,yp%,0
680 GOTO 200
690 REM ******************************
700 REM *         MOVE DOWN          *
710 REM ******************************
720 yp%=dy%:dy%=dy%-2
730 IF dy%<0 THEN dy%=0
740 PLOT dx%,yp%,0
750 GOTO 200
760 REM ******************************
770 REM *         MOVE LEFT          *
780 REM ******************************
790 px%=dx%:dx%=dx%-2
800 IF dx%<160 THEN dx%=160
810 PLOT px%,dy%,0
820 GOTO 200
830 REM ******************************
840 REM *         MOVE RIGHT         *
850 REM ******************************
860 px%=dx%:dx%=dx%+2
870 IF dx%>490 THEN dx%=490
880 PLOT px%,dy%,0
890 GOTO 200
900 REM ******************************
910 REM *         SET POINT          *
920 REM ******************************
930 point%=point%+1
940 x%(point%,1)=dx%-320
950 y%(point%,1)=dy%
960 z%(point%,1)=0
970 IF point%>1 THEN PLOT x%(point%-1,1)+320,y%(point%-1,1):DRAW 
x%(point%,1)+320,y%(point%,1),1
980 IF point%=maxi% THEN 1020
990 IF JOY(0)<>0 THEN 990
1000 IF INKEY$<>"" THEN 1000
1010 GOTO 200
1020 REM ******************************
1030 REM *         END INPUT          *
1040 REM ******************************
1050 CLS
1060 INPUT "ENTER NUMBER OF FACES";f%
1070 IF f%>50 OR f%<4 THEN 1050
1080 CLS:PRINT " PLEASE WAIT - COMPUTING POINTS MATRIX"
1090 sn=SIN(PI/(f%/2)):cs=COS(PI/(f%/2))
1100 FOR l%=2 TO f%
1110 FOR k%=1 TO point%
1120 x%(k%,l%)=x%(k%,l%-1)*cs-z%(k%,l%-1)*sn
1130 y%(k%,l%)=y%(k%,l%-1)
1140 z%(k%,l%)=z%(k%,l%-1)*cs-x%(k%,l%-1)*sn
1150 NEXT
1160 NEXT
1170 GOTO 270


----------------------------------------
GAME - Bustout! by Alexander Martin
----------------------------------------

Type in your first game

One of the most important features of the CPC464 is its ability to do a lot 
with only a minimum of programming effort. The programs in this issue 
demonstrate this facet of the system, and this version of the well known 
'breakout' style of game manages to fit all the essential features into a 
single page listing.
There's even a comprehensive range of sounds to support the visual activity.
The cursor keys or joystick control the bat that runs along the bottom of 
the screen. Stop the 'ball' (it's actually a square, but you could chose 
another character.) Line 300 sets up the bat with character 233.

Commentry

Lines
10-60		Set up the constants for the program. The sound tone and volume 
envelopes and mode.
70-130		Draws the new opening screen.
140-150		Draws the 'bat'.
160-190		Every time a life is lost (ie you miss a ball and it drops off the 
bottom of the display) this section generates a random entry for the next 
ball.
200-320		The main program loop. It 'Undraws' the ball (by overprinting the 
old position with a space), then draws the new position. The routine also 
spots the boundaries and produces an appropriate noise - and increments the 
score when the topline is eaten away.

Subroutines
330-350		This provides the'end of a life' condition if you miss the ball in 
240.
360-380		This routine, called from 220, scans the keyboard or joystick to 
move the bat.
390		Called from the midst of 260, this routine erases the block that has 
been hit by the ball by replacing it with a space character.
400-410		When the lives reach zero (line 330), this re-initialises the life 
count and score before restarting at line 60.
420		The score update routine, called from 260, 270 or 280, depending on 
which block has been knocked from the 'wall'.

----------------------------------------

10 BORDER 1:INK 0,1:INK 1,26:INK 2,24:INK 3,6
20 SPEED KEY 15,2
30 ENV 1,1,18,0,11,0,10:ENT 1,10,2,2
40 ENV 3,1,0,16,5,-3,2
50 ENV 2,5,3,3,1,-21,22,9,-3,2:ENT -2,10,2,2,5,-7,1,2,11,3,2,-4,8
60 MODE 1
70 MOVE 30,32:DRAWR 0,400,1:MOVE 608,32:DRAWR 0,400,1
80 PEN 3:LOCATE 3,1:PRINT STRING$(36,143):PEN 2:LOCATE 3,2:PRINT 
STRING$(36,143):PEN 1:FOR r=5 TO 6:LOCATE 3,r:PRINT STRING$(36,143):NEXT r
90 bx=17
100 lives=5:score=0
110 PEN 1:GOSUB 420
120 IF INKEY$<>"" THEN 120
130 GOTO 160:REM start the game
140 LOCATE bx,24:PRINT "  ";STRING$(4,131);"  "
150 RETURN
160 xa=1:ya=1:IF INT(RND*2)=1 THEN xa=-xa:REM for each life start here
170 PEN 1:GOSUB 140
180 ORIGIN 0,400
190 x=bx+4:y=11:x1=x:y1=y
200 x1=x+xa:y1=y+ya:REM start of main loop
210 IF x1=3 OR x1=38 THEN xa=-xa
220 GOSUB 360
230 IF y1=24 AND x1>bx+1 AND x1<bx+6 THEN ya=-ya:y1=y1-2:SOUND 
130,44,8,7,1,1:a=((x>bx+5)OR(x<bx+2)):IF a=-1 THEN xa=xa*a:x1=x1+xa:y1=y1+1
240 IF y1=25 THEN LOCATE x,y:PRINT " ":GOTO 330
250 GOSUB 140
260 t=TEST((16*x1)-1,-(16*y1)-1):IF t<>0 THEN 
ya=-ya:xz=x1:yz=y1:y1=y1+ya:GOSUB 390:IF t=2 THEN score=score+10:GOSUB 420
270 IF t=3 THEN score=score+20:GOSUB 420
280 IF t=1 THEN score=score+5:GOSUB 420
290 IF y1=1 THEN ya=1
300 LOCATE x,y:PRINT " ":LOCATE x1,y1:PRINT CHR$(233):x=x1:y=y1
310 IF y=1 OR x=3 OR x=38 THEN SOUND 129,78,8,7,1,1
320 GOTO 200:REM finish of main loop
330 lives=lives-1:SOUND 132,19,46,12,2,2:IF lives=0 THEN GOTO 400
340 GOSUB 420
350 GOTO 160
360 IF (INKEY(8)=0 OR INKEY(74)=0) AND bx>2 THEN bx=bx-2:RETURN
370 IF (INKEY(1)=0 OR INKEY(75)=0) AND bx<32 THEN bx=bx+2:RETURN
380 RETURN
390 LOCATE xz,yz:PRINT " ":RETURN
400 IF score>=hiscore THEN hiscore=score
410 score=0:lives=5:GOSUB 420:GOTO 60
420 SOUND 130,0,20,13,3,0,31:LOCATE 3,25:PRINT "HISCORE";hiscore;:LOCATE 
18,25:PRINT "SCORE";score:LOCATE 32,25:PRINT "LIVES";lives:RETURN


----------------------------------------
All files typed in and saved to .dsk
file (NVG) by Mr. Michael N. Till.
...The Devil's Phoenix..

Any problems or queeries please
e-mail: redstick@hotmail.co.uk
